﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Windvoice.Authorize
{
    public static class OAuthFactory
    {
        private static Dictionary<OAuthProvider, IOAuthConnector> InstanceDictionary = new Dictionary<OAuthProvider, IOAuthConnector>();

        public static IOAuthConnector CreateConnector(OAuthProvider provider)
        {
            if (!InstanceDictionary.Keys.Contains(provider))
            {
                switch (provider)
                {
                    case OAuthProvider.Sina:
                        InstanceDictionary.Add(OAuthProvider.Sina, new SinaConnector());
                        break;
                    case OAuthProvider.QQ:
                        InstanceDictionary.Add(OAuthProvider.QQ, new QQConnector());
                        break;
                    default:
                        throw new ArgumentOutOfRangeException("provider");
                }
            }

            return InstanceDictionary[provider];
        }
    }
}
